package com.nulldev.util.web.HttpServer3.legacyPages.v1;

public enum RequestType {
	GET("GET"),
	POST("POST"),
	OPTIONS("OPTIONS"),
	PUT("PUT"),
	DELETE("DELETE"),
	HEAD("HEAD"),
	TRACE("TRACE"),
	PATCH("PATCH"),
	CONNECT("CONNECT");

	private final String raw;

	private RequestType(final String raw) {
		this.raw = raw;
	}

	public String raw() {
		return this.raw;
	}

	public static RequestType fetch(final String REQUEST_TYPE) {
		for (final RequestType type : values()) {
			if (type.raw.equals(REQUEST_TYPE)) {
				return type;
			}
		}
		return GET;
	}

	public static boolean isValidMethod(final String REQUEST_TYPE) {
		for (final RequestType type : values()) {
			if (type.raw.equals(REQUEST_TYPE)) {
				return true;
			}
		}
		return false;
	}
}
